Developer Documentation

QuickTime 4 API Documentation

Inside Macintosh: Macintosh Toolbox Essentials

Previous | Chapter Top | Chapter Contents | Next |

Resizing Windows

This section describes the functions you can use to track the cursor while the user resizes a window and to draw the window in a new size.

GrowWindow

Allows the user to change the size of a window.

pascal long GrowWindow (WindowPtr theWindow,
                     Point startPt,
                     const Rect *bBox);
theWindow
A pointer to the window record of the window to drag.
startPt
The location of the cursor at the time the mouse button was first pressed, in global coordinates. Your application retrieves this point from the where field of the event record.
sizeRect
A pointer to a rectangle structure that specifies the limits on the vertical and horizontal measurements of the port rectangle, in pixels.
Although the sizeRect parameter gives the address of a structure which is in the form of the Rect data type, the four numbers in the structure represent lengths, not screen coordinates. The top , left , bottom , and right fields of the sizeRect parameter specify the minimum vertical measurement ( top ), the minimum horizontal measurement ( left ), the maximum vertical measurement ( bottom ), and the maximum horizontal measurement ( right ).
The minimum measurements must be large enough to allow a manageable rectangle; 64 pixels on a side is typical. Because the user cannot ordinarily move the cursor off the screen, you can safely set the upper bounds to the largest possible length (65,535 pixels) when you're using GrowWindow to follow cursor movements.

DESCRIPTION

The GrowWindow function displays an outline (grow image) of the window as the user moves the cursor to make the window larger or smaller; it handles all user interaction until the user releases the mouse button. After calling GrowWindow , you call the SizeWindow function (SizeWindow) to change the size of the window.

The GrowWindow function moves a dotted-line image of the window's right and lower edges around the screen, following the movements of the cursor until the mouse button is released. It returns the new dimensions, in pixels, of the resulting window: the height in the high-order word of the returned long-integer value and the width in the low-order word. You can use the functions HiWord and LoWord (described in Inside Macintosh: Operating System Utilities ) to retrieve only the high-order and low-order words, respectively.

A return value of 0 means that the new size is the same as the size of the current port rectangle.

ASSEMBLY-LANGUAGE INFORMATION

You can set the global variable DragHook to point to an optional function, defined by your application, which will be called by GrowWindow as long as the mouse button is held down. (If there's an actionProc function, the actionProc function is called first.) Note that the use of the Window Manager's global variables is not guaranteed to be compatible with system software versions later than System 6.

SizeWindow

Sets the size of a window.

pascal void SizeWindow (WindowPtr theWindow,
                     short w,
                     short h,
                     Boolean fUpdate);
theWindow
A pointer to the window record of the window to be sized.
w
The new window width, in pixels.
h
The new window height, in pixels.
fUpdate
A Boolean value that specifies whether any newly created area of the content region is to be accumulated into the update region ( true ) or not ( false ). You ordinarily pass a value of true to ensure that the area is updated. If you pass false , you're responsible for maintaining the update region yourself. For more information on adding rectangles to and removing rectangles from the update region, see InvalRect InvalRect and ValidRect ValidRect .

DESCRIPTION

The SizeWindow function changes the size of the window's graphics port rectangle to the dimensions specified by the w and h parameters, or does nothing if the values of w and h are 0. The Window Manager redraws the window in the new size, recentering the title and truncating it if necessary. Your application calls SizeWindow immediately after calling GrowWindow (GrowWindow) to adjust the window to any changes made by the user through the size box.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next